package com.tbynet.jwp.service.dto.response;

import java.io.Serializable;
import java.math.BigInteger;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * Manager层分类项响应DTO
 * 细粒度区分不同场景的返回数据，对标WordPress 4.9分类项管理系统
 *
 * 设计原则：
 * - 单一职责：每个内部类只负责一种响应场景
 * - 无状态：所有响应对象都是数据传输对象，不包含业务逻辑
 * - 完整性：提供完整的getter/setter方法和工具方法
 * - 可序列化：支持网络传输和持久化
 *
 * @author 佰亿互联
 * @version 2.0
 * @since 2025-11-04
 */
public class TermResponse implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * 基础信息响应
     * 用于列表展示、下拉选择等简单场景
     * 包含分类项的核心字段，不包含复杂关系和元数据
     */
    public static class BasicInfo implements Serializable {
        private static final long serialVersionUID = 1L;

        /** 分类项ID */
        private BigInteger termId;
        /** 分类项名称 */
        private String name;
        /** 分类项别名 */
        private String slug;
        /** 分类法类型 */
        private String taxonomy;
        /** 描述 */
        private String description;
        /** 使用计数 */
        private Integer count;
        /** 父级ID */
        private BigInteger parentId;
        /** 父级名称 */
        private String parentName;
        /** 创建时间 */
        private Date createTime;
        /** 更新时间 */
        private Date updateTime;

        // Getter和Setter方法
        public BigInteger getTermId() { return termId; }
        public void setTermId(BigInteger termId) { this.termId = termId; }

        public String getName() { return name; }
        public void setName(String name) { this.name = name; }

        public String getSlug() { return slug; }
        public void setSlug(String slug) { this.slug = slug; }

        public String getTaxonomy() { return taxonomy; }
        public void setTaxonomy(String taxonomy) { this.taxonomy = taxonomy; }

        public String getDescription() { return description; }
        public void setDescription(String description) { this.description = description; }

        public Integer getCount() { return count; }
        public void setCount(Integer count) { this.count = count; }

        public BigInteger getParentId() { return parentId; }
        public void setParentId(BigInteger parentId) { this.parentId = parentId; }

        public String getParentName() { return parentName; }
        public void setParentName(String parentName) { this.parentName = parentName; }

        public Date getCreateTime() { return createTime; }
        public void setCreateTime(Date createTime) { this.createTime = createTime; }

        public Date getUpdateTime() { return updateTime; }
        public void setUpdateTime(Date updateTime) { this.updateTime = updateTime; }
    }

    /**
     * 详细信息响应
     * 用于分类项详情页、编辑页面等需要完整信息的场景
     * 包含分类项的所有字段，包括元数据、父子关系等扩展信息
     */
    public static class DetailInfo implements Serializable {
        private static final long serialVersionUID = 1L;

        /** 分类项ID */
        private BigInteger termId;
        /** 分类项名称 */
        private String name;
        /** 分类项别名 */
        private String slug;
        /** 分类法类型 */
        private String taxonomy;
        /** 分类法ID */
        private BigInteger taxonomyId;
        /** 描述 */
        private String description;
        /** 父级ID */
        private BigInteger parentId;
        /** 父级名称 */
        private String parentName;
        /** 使用计数 */
        private Integer count;
        /** 分类项分组 */
        private Integer termGroup;
        /** 创建时间 */
        private Date createTime;
        /** 更新时间 */
        private Date updateTime;
        /** 元数据 */
        private Map<String, Object> metaData;
        /** 子分类项数量 */
        private Integer childrenCount;
        /** 完整路径 */
        private String fullPath;

        // Getter和Setter方法
        public BigInteger getTermId() { return termId; }
        public void setTermId(BigInteger termId) { this.termId = termId; }

        public String getName() { return name; }
        public void setName(String name) { this.name = name; }

        public String getSlug() { return slug; }
        public void setSlug(String slug) { this.slug = slug; }

        public String getTaxonomy() { return taxonomy; }
        public void setTaxonomy(String taxonomy) { this.taxonomy = taxonomy; }

        public BigInteger getTaxonomyId() { return taxonomyId; }
        public void setTaxonomyId(BigInteger taxonomyId) { this.taxonomyId = taxonomyId; }

        public String getDescription() { return description; }
        public void setDescription(String description) { this.description = description; }

        public BigInteger getParentId() { return parentId; }
        public void setParentId(BigInteger parentId) { this.parentId = parentId; }

        public String getParentName() { return parentName; }
        public void setParentName(String parentName) { this.parentName = parentName; }

        public Integer getCount() { return count; }
        public void setCount(Integer count) { this.count = count; }

        public Integer getTermGroup() { return termGroup; }
        public void setTermGroup(Integer termGroup) { this.termGroup = termGroup; }

        public Date getCreateTime() { return createTime; }
        public void setCreateTime(Date createTime) { this.createTime = createTime; }

        public Date getUpdateTime() { return updateTime; }
        public void setUpdateTime(Date updateTime) { this.updateTime = updateTime; }

        public Map<String, Object> getMetaData() { return metaData; }
        public void setMetaData(Map<String, Object> metaData) { this.metaData = metaData; }

        public Integer getChildrenCount() { return childrenCount; }
        public void setChildrenCount(Integer childrenCount) { this.childrenCount = childrenCount; }

        public String getFullPath() { return fullPath; }
        public void setFullPath(String fullPath) { this.fullPath = fullPath; }
    }

    /**
     * 列表响应
     * 用于分页查询、搜索等列表场景
     * 包含分页信息、搜索条件等上下文信息
     */
    public static class ListResult implements Serializable {
        private static final long serialVersionUID = 1L;

        /** 分类项列表 */
        private List<BasicInfo> terms;
        /** 总记录数 */
        private int totalCount;
        /** 总页数 */
        private int totalPage;
        /** 当前页码 */
        private int pageNumber;
        /** 每页大小 */
        private int pageSize;
        /** 分类法类型 */
        private String taxonomy;
        /** 搜索关键词 */
        private String searchKeyword;
        /** 文章ID（用于关联查询） */
        private BigInteger postId;
        /** 附加信息 */
        private Map<String, Object> extraInfo;

        /**
         * 默认构造函数
         */
        public ListResult() {}

        // Getter和Setter方法
        public List<BasicInfo> getTerms() { return terms; }
        public void setTerms(List<BasicInfo> terms) { this.terms = terms; }

        public int getTotalCount() { return totalCount; }
        public void setTotalCount(int totalCount) { this.totalCount = totalCount; }

        public int getTotalPage() { return totalPage; }
        public void setTotalPage(int totalPage) { this.totalPage = totalPage; }

        public int getPageNumber() { return pageNumber; }
        public void setPageNumber(int pageNumber) { this.pageNumber = pageNumber; }

        public int getPageSize() { return pageSize; }
        public void setPageSize(int pageSize) { this.pageSize = pageSize; }

        public String getTaxonomy() { return taxonomy; }
        public void setTaxonomy(String taxonomy) { this.taxonomy = taxonomy; }

        public String getSearchKeyword() { return searchKeyword; }
        public void setSearchKeyword(String searchKeyword) { this.searchKeyword = searchKeyword; }

        public BigInteger getPostId() { return postId; }
        public void setPostId(BigInteger postId) { this.postId = postId; }

        public Map<String, Object> getExtraInfo() { return extraInfo; }
        public void setExtraInfo(Map<String, Object> extraInfo) { this.extraInfo = extraInfo; }

        /**
         * 检查是否有上一页
         * @return true表示有上一页，false表示没有
         */
        public boolean hasPrevious() {
            return pageNumber > 1;
        }

        /**
         * 检查是否有下一页
         * @return true表示有下一页，false表示没有
         */
        public boolean hasNext() {
            return pageNumber < totalPage;
        }

        /**
         * 获取分页信息摘要
         * @return 格式化的分页信息字符串
         */
        public String getPaginationInfo() {
            return String.format("第 %d/%d 页, 每页 %d 条, 共 %d 条",
                    pageNumber, totalPage, pageSize, totalCount);
        }
    }

    /**
     * 层级结构响应
     * 用于树形结构展示、导航菜单等层级场景
     * 支持无限级嵌套，包含深度信息
     */
    public static class HierarchyResult implements Serializable {
        private static final long serialVersionUID = 1L;

        /** 层级分类项列表 */
        private List<HierarchyTerm> hierarchyTerms;
        /** 总数量 */
        private Long total;
        /** 分类法类型 */
        private String taxonomy;
        /** 父级ID */
        private BigInteger parentId;
        /** 最大深度 */
        private Integer maxDepth;

        /**
         * 层级分类项节点
         * 表示树形结构中的一个节点，包含子节点信息
         */
        public static class HierarchyTerm {
            /** 分类项ID */
            private BigInteger termId;
            /** 分类项名称 */
            private String name;
            /** 分类项别名 */
            private String slug;
            /** 分类法类型 */
            private String taxonomy;
            /** 使用计数 */
            private Integer count;
            /** 深度（从0开始） */
            private Integer depth;
            /** 子分类项列表 */
            private List<HierarchyTerm> children;

            // Getter和Setter方法
            public BigInteger getTermId() { return termId; }
            public void setTermId(BigInteger termId) { this.termId = termId; }

            public String getName() { return name; }
            public void setName(String name) { this.name = name; }

            public String getSlug() { return slug; }
            public void setSlug(String slug) { this.slug = slug; }

            public String getTaxonomy() { return taxonomy; }
            public void setTaxonomy(String taxonomy) { this.taxonomy = taxonomy; }

            public Integer getCount() { return count; }
            public void setCount(Integer count) { this.count = count; }

            public Integer getDepth() { return depth; }
            public void setDepth(Integer depth) { this.depth = depth; }

            public List<HierarchyTerm> getChildren() { return children; }
            public void setChildren(List<HierarchyTerm> children) { this.children = children; }
        }

        // Getter和Setter方法
        public List<HierarchyTerm> getHierarchyTerms() { return hierarchyTerms; }
        public void setHierarchyTerms(List<HierarchyTerm> hierarchyTerms) { this.hierarchyTerms = hierarchyTerms; }

        public Long getTotal() { return total; }
        public void setTotal(Long total) { this.total = total; }

        public String getTaxonomy() { return taxonomy; }
        public void setTaxonomy(String taxonomy) { this.taxonomy = taxonomy; }

        public BigInteger getParentId() { return parentId; }
        public void setParentId(BigInteger parentId) { this.parentId = parentId; }

        public Integer getMaxDepth() { return maxDepth; }
        public void setMaxDepth(Integer maxDepth) { this.maxDepth = maxDepth; }
    }

    /**
     * 统计信息响应
     * 用于仪表盘、统计报表等数据展示场景
     * 包含各类统计指标和趋势数据
     */
    public static class Statistics implements Serializable {
        private static final long serialVersionUID = 1L;

        /** 总分类项数量 */
        private Long totalTerms;
        /** 各分类法统计，key为分类法，value为数量 */
        private Map<String, Long> taxonomyCounts;
        /** 空分类项统计，key为分类法，value为空分类项数量 */
        private Map<String, Long> emptyCounts;
        /** 最近创建的分类项 */
        private List<BasicInfo> recentTerms;
        /** 最常用的分类项 */
        private List<BasicInfo> popularTerms;

        // Getter和Setter方法
        public Long getTotalTerms() { return totalTerms; }
        public void setTotalTerms(Long totalTerms) { this.totalTerms = totalTerms; }

        public Map<String, Long> getTaxonomyCounts() { return taxonomyCounts; }
        public void setTaxonomyCounts(Map<String, Long> taxonomyCounts) { this.taxonomyCounts = taxonomyCounts; }

        public Map<String, Long> getEmptyCounts() { return emptyCounts; }
        public void setEmptyCounts(Map<String, Long> emptyCounts) { this.emptyCounts = emptyCounts; }

        public List<BasicInfo> getRecentTerms() { return recentTerms; }
        public void setRecentTerms(List<BasicInfo> recentTerms) { this.recentTerms = recentTerms; }

        public List<BasicInfo> getPopularTerms() { return popularTerms; }
        public void setPopularTerms(List<BasicInfo> popularTerms) { this.popularTerms = popularTerms; }
    }

    /**
     * 批量操作结果响应
     * 用于批量删除、批量清理等操作的返回结果
     * 包含详细的成功/失败统计信息
     */
    public static class BatchOperationResult implements Serializable {
        private static final long serialVersionUID = 1L;

        /** 总操作数量 */
        private int totalCount;
        /** 成功数量 */
        private int successCount;
        /** 失败数量 */
        private int failedCount;
        /** 成功率 */
        private double successRate;
        /** 成功的分类项ID列表 */
        private List<BigInteger> successIds;
        /** 失败的分类项ID列表 */
        private List<BigInteger> failedIds;
        /** 错误消息列表 */
        private List<String> errorMessages;
        /** 分类法类型 */
        private String taxonomy;
        /** 处理耗时(毫秒) */
        private Long processingTimeMs;
        /** 完成时间 */
        private Date completedAt;
        /** 操作类型 */
        private String operationType;

        /**
         * 默认构造函数
         */
        public BatchOperationResult() {
            this.completedAt = new Date();
        }

        /**
         * 带参数构造函数
         * @param totalCount 总操作数量
         * @param successCount 成功数量
         * @param successIds 成功的ID列表
         * @param failedIds 失败的ID列表
         * @param taxonomy 分类法类型
         */
        public BatchOperationResult(int totalCount, int successCount, List<BigInteger> successIds,
                                    List<BigInteger> failedIds, String taxonomy) {
            this();
            this.totalCount = totalCount;
            this.successCount = successCount;
            this.failedCount = failedIds != null ? failedIds.size() : 0;
            this.successRate = totalCount > 0 ? (double) successCount / totalCount * 100 : 0;
            this.successIds = successIds;
            this.failedIds = failedIds;
            this.taxonomy = taxonomy;
        }

        // Getter和Setter方法
        public int getTotalCount() { return totalCount; }
        public void setTotalCount(int totalCount) { this.totalCount = totalCount; }

        public int getSuccessCount() { return successCount; }
        public void setSuccessCount(int successCount) {
            this.successCount = successCount;
            // 自动重新计算成功率
            if (totalCount > 0) {
                this.successRate = (double) successCount / totalCount * 100;
            }
        }

        public int getFailedCount() { return failedCount; }
        public void setFailedCount(int failedCount) { this.failedCount = failedCount; }

        public double getSuccessRate() { return successRate; }
        public void setSuccessRate(double successRate) { this.successRate = successRate; }

        public List<BigInteger> getSuccessIds() { return successIds; }
        public void setSuccessIds(List<BigInteger> successIds) { this.successIds = successIds; }

        public List<BigInteger> getFailedIds() { return failedIds; }
        public void setFailedIds(List<BigInteger> failedIds) {
            this.failedIds = failedIds;
            this.failedCount = failedIds != null ? failedIds.size() : 0;
        }

        public List<String> getErrorMessages() { return errorMessages; }
        public void setErrorMessages(List<String> errorMessages) { this.errorMessages = errorMessages; }

        public String getTaxonomy() { return taxonomy; }
        public void setTaxonomy(String taxonomy) { this.taxonomy = taxonomy; }

        public Long getProcessingTimeMs() { return processingTimeMs; }
        public void setProcessingTimeMs(Long processingTimeMs) { this.processingTimeMs = processingTimeMs; }

        public Date getCompletedAt() { return completedAt; }
        public void setCompletedAt(Date completedAt) { this.completedAt = completedAt; }

        public String getOperationType() { return operationType; }
        public void setOperationType(String operationType) { this.operationType = operationType; }

        /**
         * 检查是否全部成功
         * @return true表示全部成功，false表示有失败
         */
        public boolean isAllSuccess() {
            return successCount == totalCount && failedCount == 0;
        }

        /**
         * 检查是否全部失败
         * @return true表示全部失败，false表示有成功
         */
        public boolean isAllFailed() {
            return successCount == 0 && failedCount == totalCount;
        }

        /**
         * 获取操作结果摘要
         * @return 格式化的结果摘要字符串
         */
        public String getSummary() {
            return String.format("批量操作结果: 总数=%d, 成功=%d, 失败=%d, 成功率=%.1f%%",
                    totalCount, successCount, failedCount, successRate);
        }

        @Override
        public String toString() {
            return getSummary();
        }
    }

    /**
     * 合并结果响应
     * 用于分类项合并操作的返回结果
     * 记录源分类项和目标分类项的合并详情
     */
    public static class MergeResult implements Serializable {
        private static final long serialVersionUID = 1L;

        /** 是否成功 */
        private boolean success;
        /** 源分类项ID */
        private BigInteger sourceTermId;
        /** 目标分类项ID */
        private BigInteger targetTermId;
        /** 源分类项名称 */
        private String sourceTermName;
        /** 目标分类项名称 */
        private String targetTermName;
        /** 合并的文章数量 */
        private int mergedPostCount;
        /** 消息 */
        private String message;
        /** 合并时间 */
        private Date mergedAt;

        /**
         * 默认构造函数
         */
        public MergeResult() {
            this.mergedAt = new Date();
        }

        // Getter和Setter方法
        public boolean isSuccess() { return success; }
        public void setSuccess(boolean success) { this.success = success; }

        public BigInteger getSourceTermId() { return sourceTermId; }
        public void setSourceTermId(BigInteger sourceTermId) { this.sourceTermId = sourceTermId; }

        public BigInteger getTargetTermId() { return targetTermId; }
        public void setTargetTermId(BigInteger targetTermId) { this.targetTermId = targetTermId; }

        public String getSourceTermName() { return sourceTermName; }
        public void setSourceTermName(String sourceTermName) { this.sourceTermName = sourceTermName; }

        public String getTargetTermName() { return targetTermName; }
        public void setTargetTermName(String targetTermName) { this.targetTermName = targetTermName; }

        public int getMergedPostCount() { return mergedPostCount; }
        public void setMergedPostCount(int mergedPostCount) { this.mergedPostCount = mergedPostCount; }

        public String getMessage() { return message; }
        public void setMessage(String message) { this.message = message; }

        public Date getMergedAt() { return mergedAt; }
        public void setMergedAt(Date mergedAt) { this.mergedAt = mergedAt; }
    }

    /**
     * 操作结果响应
     * 用于通用操作的结果返回
     * 包含操作状态、消息和错误信息
     */
    public static class OperationResult implements Serializable {
        private static final long serialVersionUID = 1L;

        /** 是否成功 */
        private boolean success;
        /** 消息 */
        private String message;
        /** 分类项ID */
        private BigInteger termId;
        /** 分类法类型 */
        private String taxonomy;
        /** 操作时间 */
        private Date operatedAt;
        /** 错误代码 */
        private String errorCode;
        /** 附加数据 */
        private Map<String, Object> extraData;

        /**
         * 默认构造函数
         */
        public OperationResult() {
            this.operatedAt = new Date();
        }

        // Getter和Setter方法
        public boolean isSuccess() { return success; }
        public void setSuccess(boolean success) { this.success = success; }

        public String getMessage() { return message; }
        public void setMessage(String message) { this.message = message; }

        public BigInteger getTermId() { return termId; }
        public void setTermId(BigInteger termId) { this.termId = termId; }

        public String getTaxonomy() { return taxonomy; }
        public void setTaxonomy(String taxonomy) { this.taxonomy = taxonomy; }

        public Date getOperatedAt() { return operatedAt; }
        public void setOperatedAt(Date operatedAt) { this.operatedAt = operatedAt; }

        public String getErrorCode() { return errorCode; }
        public void setErrorCode(String errorCode) { this.errorCode = errorCode; }

        public Map<String, Object> getExtraData() { return extraData; }
        public void setExtraData(Map<String, Object> extraData) { this.extraData = extraData; }
    }

    /**
     * 转换结果响应
     * 用于分类项分类法转换操作的返回结果
     * 记录源分类项和目标分类项的转换关系
     */
    public static class TransformResult implements Serializable {
        private static final long serialVersionUID = 1L;

        /** 是否成功 */
        private boolean success;
        /** 源分类项ID */
        private BigInteger sourceTermId;
        /** 新分类项ID */
        private BigInteger newTermId;
        /** 源分类法类型 */
        private String sourceTaxonomy;
        /** 目标分类法类型 */
        private String targetTaxonomy;
        /** 源分类项名称 */
        private String sourceTermName;
        /** 新分类项名称 */
        private String newTermName;
        /** 消息 */
        private String message;
        /** 转换时间 */
        private Date transformedAt;
        /** 错误代码 */
        private String errorCode;

        /**
         * 默认构造函数
         */
        public TransformResult() {
            this.transformedAt = new Date();
        }

        // Getter和Setter方法
        public boolean isSuccess() { return success; }
        public void setSuccess(boolean success) { this.success = success; }

        public BigInteger getSourceTermId() { return sourceTermId; }
        public void setSourceTermId(BigInteger sourceTermId) { this.sourceTermId = sourceTermId; }

        public BigInteger getNewTermId() { return newTermId; }
        public void setNewTermId(BigInteger newTermId) { this.newTermId = newTermId; }

        public String getSourceTaxonomy() { return sourceTaxonomy; }
        public void setSourceTaxonomy(String sourceTaxonomy) { this.sourceTaxonomy = sourceTaxonomy; }

        public String getTargetTaxonomy() { return targetTaxonomy; }
        public void setTargetTaxonomy(String targetTaxonomy) { this.targetTaxonomy = targetTaxonomy; }

        public String getSourceTermName() { return sourceTermName; }
        public void setSourceTermName(String sourceTermName) { this.sourceTermName = sourceTermName; }

        public String getNewTermName() { return newTermName; }
        public void setNewTermName(String newTermName) { this.newTermName = newTermName; }

        public String getMessage() { return message; }
        public void setMessage(String message) { this.message = message; }

        public Date getTransformedAt() { return transformedAt; }
        public void setTransformedAt(Date transformedAt) { this.transformedAt = transformedAt; }

        public String getErrorCode() { return errorCode; }
        public void setErrorCode(String errorCode) { this.errorCode = errorCode; }
    }

    /**
     * 分类法信息响应
     * 用于分类法详情的返回结果
     * 包含分类法的配置信息和统计信息
     */
    public static class TaxonomyInfo implements Serializable {
        private static final long serialVersionUID = 1L;

        /** 分类法类型 */
        private String taxonomy;
        /** 分类法标签 */
        private String label;
        /** 分类法描述 */
        private String description;
        /** 是否层级结构 */
        private Boolean hierarchical;
        /** 是否公开 */
        private Boolean publicFlag;
        /** 分类项数量 */
        private Long termCount;
        /** 默认分类项 */
        private BasicInfo defaultTerm;
        /** 分类法设置 */
        private Map<String, Object> settings;

        // Getter和Setter方法
        public String getTaxonomy() { return taxonomy; }
        public void setTaxonomy(String taxonomy) { this.taxonomy = taxonomy; }

        public String getLabel() { return label; }
        public void setLabel(String label) { this.label = label; }

        public String getDescription() { return description; }
        public void setDescription(String description) { this.description = description; }

        public Boolean getHierarchical() { return hierarchical; }
        public void setHierarchical(Boolean hierarchical) { this.hierarchical = hierarchical; }

        public Boolean getPublicFlag() { return publicFlag; }
        public void setPublicFlag(Boolean publicFlag) { this.publicFlag = publicFlag; }

        public Long getTermCount() { return termCount; }
        public void setTermCount(Long termCount) { this.termCount = termCount; }

        public BasicInfo getDefaultTerm() { return defaultTerm; }
        public void setDefaultTerm(BasicInfo defaultTerm) { this.defaultTerm = defaultTerm; }

        public Map<String, Object> getSettings() { return settings; }
        public void setSettings(Map<String, Object> settings) { this.settings = settings; }
    }

    /**
     * 路径结果响应
     * 用于分类项路径查询的返回结果
     * 显示从根分类项到当前分类项的完整路径
     */
    public static class PathResult implements Serializable {
        private static final long serialVersionUID = 1L;

        /** 分类项ID */
        private BigInteger termId;
        /** 分类法类型 */
        private String taxonomy;
        /** 分类项路径列表 */
        private List<BasicInfo> path;
        /** 路径深度 */
        private Integer depth;
        /** 完整路径字符串 */
        private String fullPath;

        // Getter和Setter方法
        public BigInteger getTermId() { return termId; }
        public void setTermId(BigInteger termId) { this.termId = termId; }

        public String getTaxonomy() { return taxonomy; }
        public void setTaxonomy(String taxonomy) { this.taxonomy = taxonomy; }

        public List<BasicInfo> getPath() { return path; }
        public void setPath(List<BasicInfo> path) { this.path = path; }

        public Integer getDepth() { return depth; }
        public void setDepth(Integer depth) { this.depth = depth; }

        public String getFullPath() { return fullPath; }
        public void setFullPath(String fullPath) { this.fullPath = fullPath; }
    }

    /**
     * 关系检查响应
     * 用于分类项关系检查的返回结果
     * 检查两个分类项之间的层级关系
     */
    public static class RelationCheckResult implements Serializable {
        private static final long serialVersionUID = 1L;

        /** 分类项1 ID */
        private BigInteger termId1;
        /** 分类项2 ID */
        private BigInteger termId2;
        /** 分类法类型 */
        private String taxonomy;
        /** 是否为祖先 */
        private Boolean isAncestor;
        /** 是否为后代 */
        private Boolean isDescendant;
        /** 是否为兄弟节点 */
        private Boolean isSibling;
        /** 关系深度 */
        private Integer relationshipDepth;

        // Getter和Setter方法
        public BigInteger getTermId1() { return termId1; }
        public void setTermId1(BigInteger termId1) { this.termId1 = termId1; }

        public BigInteger getTermId2() { return termId2; }
        public void setTermId2(BigInteger termId2) { this.termId2 = termId2; }

        public String getTaxonomy() { return taxonomy; }
        public void setTaxonomy(String taxonomy) { this.taxonomy = taxonomy; }

        public Boolean getIsAncestor() { return isAncestor; }
        public void setIsAncestor(Boolean isAncestor) { this.isAncestor = isAncestor; }

        public Boolean getIsDescendant() { return isDescendant; }
        public void setIsDescendant(Boolean isDescendant) { this.isDescendant = isDescendant; }

        public Boolean getIsSibling() { return isSibling; }
        public void setIsSibling(Boolean isSibling) { this.isSibling = isSibling; }

        public Integer getRelationshipDepth() { return relationshipDepth; }
        public void setRelationshipDepth(Integer relationshipDepth) { this.relationshipDepth = relationshipDepth; }
    }

    /**
     * 别名更新响应
     * 用于分类项别名更新操作的返回结果
     * 记录别名变更的详细信息
     */
    public static class SlugUpdateResult implements Serializable {
        private static final long serialVersionUID = 1L;

        /** 是否成功 */
        private boolean success;
        /** 分类项ID */
        private BigInteger termId;
        /** 原别名 */
        private String oldSlug;
        /** 新别名 */
        private String newSlug;
        /** 分类项名称 */
        private String termName;
        /** 消息 */
        private String message;
        /** 更新时间 */
        private Date updatedAt;

        /**
         * 默认构造函数
         */
        public SlugUpdateResult() {
            this.updatedAt = new Date();
        }

        // Getter和Setter方法
        public boolean isSuccess() { return success; }
        public void setSuccess(boolean success) { this.success = success; }

        public BigInteger getTermId() { return termId; }
        public void setTermId(BigInteger termId) { this.termId = termId; }

        public String getOldSlug() { return oldSlug; }
        public void setOldSlug(String oldSlug) { this.oldSlug = oldSlug; }

        public String getNewSlug() { return newSlug; }
        public void setNewSlug(String newSlug) { this.newSlug = newSlug; }

        public String getTermName() { return termName; }
        public void setTermName(String termName) { this.termName = termName; }

        public String getMessage() { return message; }
        public void setMessage(String message) { this.message = message; }

        public Date getUpdatedAt() { return updatedAt; }
        public void setUpdatedAt(Date updatedAt) { this.updatedAt = updatedAt; }
    }

    /**
     * 使用分析响应
     * 用于分类项使用情况分析的返回结果
     * 包含使用趋势、热门分类项等分析数据
     */
    public static class UsageAnalysisResult implements Serializable {
        private static final long serialVersionUID = 1L;

        /** 分类法类型 */
        private String taxonomy;
        /** 总使用量 */
        private Long totalUsage;
        /** 分析周期（天） */
        private Integer analysisPeriod;
        /** 每日使用量统计 */
        private Map<String, Long> dailyUsage;
        /** 趋势上升的分类项 */
        private List<BasicInfo> trendingTerms;
        /** 趋势下降的分类项 */
        private List<BasicInfo> decliningTerms;
        /** 分析洞察 */
        private Map<String, Object> insights;

        // Getter和Setter方法
        public String getTaxonomy() { return taxonomy; }
        public void setTaxonomy(String taxonomy) { this.taxonomy = taxonomy; }

        public Integer getAnalysisPeriod() { return analysisPeriod; }
        public void setAnalysisPeriod(Integer analysisPeriod) { this.analysisPeriod = analysisPeriod; }

        public Long getTotalUsage() { return totalUsage; }
        public void setTotalUsage(Long totalUsage) { this.totalUsage = totalUsage; }

        public Map<String, Long> getDailyUsage() { return dailyUsage; }
        public void setDailyUsage(Map<String, Long> dailyUsage) { this.dailyUsage = dailyUsage; }

        public List<BasicInfo> getTrendingTerms() { return trendingTerms; }
        public void setTrendingTerms(List<BasicInfo> trendingTerms) { this.trendingTerms = trendingTerms; }

        public List<BasicInfo> getDecliningTerms() { return decliningTerms; }
        public void setDecliningTerms(List<BasicInfo> decliningTerms) { this.decliningTerms = decliningTerms; }

        public Map<String, Object> getInsights() { return insights; }
        public void setInsights(Map<String, Object> insights) { this.insights = insights; }
    }

    /**
     * 缓存清理响应
     * 用于缓存清理操作的返回结果
     * 记录清理的详细统计信息
     */
    public static class CacheCleanResult implements Serializable {
        private static final long serialVersionUID = 1L;

        /** 是否成功 */
        private boolean success;
        /** 清理数量 */
        private int cleanedCount;
        /** 清理的分类项ID列表 */
        private List<BigInteger> cleanedTermIds;
        /** 分类法类型 */
        private String taxonomy;
        /** 消息 */
        private String message;
        /** 清理耗时(毫秒) */
        private Long cleanTimeMs;
        /** 清理时间 */
        private Date cleanedAt;
        /** 详细的清理统计 */
        private Map<String, Integer> cleanStats;

        /**
         * 默认构造函数
         */
        public CacheCleanResult() {
            this.cleanedAt = new Date();
        }

        // Getter和Setter方法
        public boolean isSuccess() { return success; }
        public void setSuccess(boolean success) { this.success = success; }

        public int getCleanedCount() { return cleanedCount; }
        public void setCleanedCount(int cleanedCount) { this.cleanedCount = cleanedCount; }

        public List<BigInteger> getCleanedTermIds() { return cleanedTermIds; }
        public void setCleanedTermIds(List<BigInteger> cleanedTermIds) { this.cleanedTermIds = cleanedTermIds; }

        public String getTaxonomy() { return taxonomy; }
        public void setTaxonomy(String taxonomy) { this.taxonomy = taxonomy; }

        public String getMessage() { return message; }
        public void setMessage(String message) { this.message = message; }

        public Long getCleanTimeMs() { return cleanTimeMs; }
        public void setCleanTimeMs(Long cleanTimeMs) { this.cleanTimeMs = cleanTimeMs; }

        public Date getCleanedAt() { return cleanedAt; }
        public void setCleanedAt(Date cleanedAt) { this.cleanedAt = cleanedAt; }

        public Map<String, Integer> getCleanStats() { return cleanStats; }
        public void setCleanStats(Map<String, Integer> cleanStats) { this.cleanStats = cleanStats; }
    }

    /**
     * 完整性检查响应
     * 用于数据完整性检查的返回结果
     * 识别数据不一致问题并提供修复建议
     */
    public static class IntegrityCheckResult implements Serializable {
        private static final long serialVersionUID = 1L;

        /** 分类法类型 */
        private String taxonomy;
        /** 数据是否一致 */
        private Boolean isConsistent;
        /** 问题列表 */
        private List<String> issues;
        /** 孤儿分类项数量 */
        private Integer orphanedTerms;
        /** 计数不一致数量 */
        private Integer inconsistentCounts;
        /** 修复建议 */
        private String repairSuggestion;
        /** 检查时间 */
        private Date checkedAt;

        // Getter和Setter方法
        public String getTaxonomy() { return taxonomy; }
        public void setTaxonomy(String taxonomy) { this.taxonomy = taxonomy; }

        public Boolean getIsConsistent() { return isConsistent; }
        public void setIsConsistent(Boolean isConsistent) { this.isConsistent = isConsistent; }

        public List<String> getIssues() { return issues; }
        public void setIssues(List<String> issues) { this.issues = issues; }

        public Integer getOrphanedTerms() { return orphanedTerms; }
        public void setOrphanedTerms(Integer orphanedTerms) { this.orphanedTerms = orphanedTerms; }

        public Integer getInconsistentCounts() { return inconsistentCounts; }
        public void setInconsistentCounts(Integer inconsistentCounts) { this.inconsistentCounts = inconsistentCounts; }

        public String getRepairSuggestion() { return repairSuggestion; }
        public void setRepairSuggestion(String repairSuggestion) { this.repairSuggestion = repairSuggestion; }

        public Date getCheckedAt() { return checkedAt; }
        public void setCheckedAt(Date checkedAt) { this.checkedAt = checkedAt; }
    }

    /**
     * 推荐结果响应
     * 用于分类项推荐功能的返回结果
     * 基于文章内容和用户行为推荐相关分类项
     */
    public static class RecommendationResult implements Serializable {
        private static final long serialVersionUID = 1L;

        /** 文章ID */
        private BigInteger postId;
        /** 分类法类型 */
        private String taxonomy;
        /** 推荐的分类项 */
        private List<BasicInfo> recommendedTerms;
        /** 置信度分数 */
        private Map<String, Double> confidenceScores;
        /** 推荐原因 */
        private String recommendationReason;
        /** 生成时间 */
        private Date generatedAt;

        // Getter和Setter方法
        public BigInteger getPostId() { return postId; }
        public void setPostId(BigInteger postId) { this.postId = postId; }

        public String getTaxonomy() { return taxonomy; }
        public void setTaxonomy(String taxonomy) { this.taxonomy = taxonomy; }

        public List<BasicInfo> getRecommendedTerms() { return recommendedTerms; }
        public void setRecommendedTerms(List<BasicInfo> recommendedTerms) { this.recommendedTerms = recommendedTerms; }

        public Map<String, Double> getConfidenceScores() { return confidenceScores; }
        public void setConfidenceScores(Map<String, Double> confidenceScores) { this.confidenceScores = confidenceScores; }

        public String getRecommendationReason() { return recommendationReason; }
        public void setRecommendationReason(String recommendationReason) { this.recommendationReason = recommendationReason; }

        public Date getGeneratedAt() { return generatedAt; }
        public void setGeneratedAt(Date generatedAt) { this.generatedAt = generatedAt; }
    }
}